//implementation of the geffe generator
//this version uses 32-bit shift register 
#include "word32.h"
#include "lfsr32.h"
#include "BitVector32.h"

class Geffe{
 private:
  lfsr32 lfsr1,lfsr2,lfsr3; //the three LFSR

 public:
  //default constructor
  Geffe(){}

  //constructor that takes the length of the LFSRs as input
  Geffe(int l1, int l2, int l3){
    lfsr1.resize(l1);
    lfsr2.resize(l2);
    lfsr3.resize(l3);
  }

  //initiate feedback polyniomial i i={1,2,3}
  void initPoly(int i,word32 poly){
    if(i==1)
      lfsr1.initPoly(poly);
    if(i==2)
      lfsr2.initPoly(poly);
    if(i==3)
      lfsr3.initPoly(poly);
  }

  //initiate the Key (equal to the state of the LFSR)
  //thus we consider three keys here K=(K1,K2,K3)
  void initKey(int i,word32 key){
    if(i==1)
      lfsr1.initState(key);
    if(i==2)
      lfsr2.initState(key);
    if(i==3)
      lfsr3.initState(key);
  }

  //generate one bit of keystream
  int generateKeyStream();

  //generate 32 bit of keystream
  word32 generateKeyStream32();

};
